package com.hyg.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Author: HuangYuGuang
 * Date: 2023/4/15
 */
public class RegexUtil {
    /**
     * 车牌号码
     */
    public static final String REGEX_PLATE_NUMBER = "^[\u0391-\uFFE5]{1}[a-zA-Z0-9]{6}$";
    /**
     * 证件号码
     */
    public static final String REGEX_ID_CODE = "^[a-zA-Z0-9]+$";
    /**
     * 编码
     */
    public static final String REGEX_CODE = "^[a-zA-Z0-9]+$";
    /**
     * 固定电话编码
     */
    public static final String REGEX_PHONE_NUMBER = "0\\d{2,3}-[0-9]+";
    /**
     * 邮政编码
     */
    public static final String REGEX_POST_CODE = "\\d{6}";
    /**
     * 面积
     */
    public static final String REGEX_AREA = "\\d*.?\\d*";
    /**
     * 手机号码
     */
    public static final String REGEX_MOBILE_NUMBER = "\\d{11}";
    /**
     * 银行帐号
     */
    public static final String REGEX_ACCOUNT_NUMBER = "\\d{16,21}";
    /**
     * 中文正则
     */
    private static String REGEX_CHINESE = "[\u4e00-\u9fa5]";

    /**
     * 车牌号码是否正确
     */
    public static boolean isPlateNumber(String s) {
        Matcher m = Pattern.compile(REGEX_PLATE_NUMBER).matcher(s);
        return m.matches();
    }

    /**
     * 证件号码是否正确
     */
    public static boolean isIDCode(String s) {
        Matcher m = Pattern.compile(REGEX_ID_CODE).matcher(s);
        return m.matches();
    }

    /**
     * 编码是否正确
     */
    public static boolean isCode(String s) {
        Matcher m = Pattern.compile(REGEX_CODE).matcher(s);
        return m.matches();
    }

    /**
     * 固话编码是否正确
     */
    public static boolean isPhoneNumber(String s) {
        Matcher m = Pattern.compile(REGEX_PHONE_NUMBER).matcher(s);
        return m.matches();
    }

    /**
     * 邮政编码是否正确
     */
    public static boolean isPostCode(String s) {
        Matcher m = Pattern.compile(REGEX_POST_CODE).matcher(s);
        return m.matches();
    }

    /**
     * 面积是否正确
     */
    public static boolean isArea(String s) {
        Matcher m = Pattern.compile(REGEX_AREA).matcher(s);
        return m.matches();
    }

    /**
     * 手机号码否正确
     */
    public static boolean isMobileNumber(String s) {
        Matcher m = Pattern.compile(REGEX_MOBILE_NUMBER).matcher(s);
        return m.matches();
    }

    /**
     * 银行账号否正确
     */
    public static boolean isAccountNumber(String s) {
        Matcher m = Pattern.compile(REGEX_ACCOUNT_NUMBER).matcher(s);
        return m.matches();
    }
}
